package com.example.suntest.entity;

import lombok.Getter;

/**
 * @version 1.0
 * @Package: com.example.suntest.entity
 * @ClassName: TestDTO
 * @Author: sgq
 * @Date: 2024/8/12 16:40
 * @Description: TODD
 */
@Getter
public class TestDTO {
    private Integer id;
    private Integer soId;
    private Integer qutoId;
    private Integer type;

    public TestDTO() {
    }

    public TestDTO(Integer id, Integer soId, Integer qutoId, Integer type) {
        this.id = id;
        this.soId = soId;
        this.qutoId = qutoId;
        this.type = type;
        validate();
    }

    public void setType(Integer type) {
        this.type = type;
        validate();
    }

    public void setId(Integer id) {
        this.id = id;
        validate();
    }

    public void setSoId(Integer soId) {
        this.soId = soId;
        validate();
    }

    public void setQutoId(Integer qutoId) {
        this.qutoId = qutoId;
        validate();
    }



    public void validate(){
        if(this.type != null && !this.type.equals("")){
            if(this.type==1 && this.id==null){
                throw new RuntimeException("id不能为空");
            }else if(this.type==2 && this.soId==null){
                throw new RuntimeException("soId不能为空");
            }else if(this.type==3 && this.qutoId==null){
                throw new RuntimeException("qutoId不能为空");
            }
        }
    }
}
